import Vue from 'vue'
import Vuex from 'vuex'


// cnpm i vuex-persistedstate -S
import createPersistedState from 'vuex-persistedstate'  //数据持久化
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    login:false,
    musicData:{
      coverImgUrl:"",
      tracks:[]
    },  //歌单列表
    musiclistts:{
      coverImgUrl:"",
      tracks:[]
    },
    searchcontent:[],
    userId:""
  },
  mutations: {
    // 登录状态修改
    setLogin(state,bol){
      state.login = bol;
    },
    // 歌单列表
    musicDataFun(state,obj){
      state.musicData = obj;
    },
    // 深拷贝歌单列表
    musiclisttsFun(state,obj){
      state.musiclistts = obj
    },
    searchcontentFun(state,obj){
      state.searchcontent = obj;
    },
    userIdFun(state,id){
      state.userId =  id;
    },
    clearId(state){
      state.userId = "";
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [createPersistedState({
    storage:window.sessionStorage
  })]
})
